package fr.resasante.spring3.controller.view;

import javax.naming.NamingException;

import org.springframework.web.servlet.ModelAndView;

/**
 * Class for getting system properties
 * 
 * @author GEFFROY-DE-VILLEBLAN
 * 
 */
public final class CommonView {
	/**
	 * class instance
	 */
	private static volatile CommonView instance = null;

	/**
	 * Method returning a Singleton class instance
	 * 
	 * @return Singleton instance
	 * @throws NamingException
	 */
	public final static CommonView getInstance() {
		if (CommonView.instance == null) {
			synchronized (CommonView.class) {
				if (CommonView.instance == null) {
					CommonView.instance = new CommonView();
				}
			}
		}
		return CommonView.instance;
	}

	/**
	 * Constructor
	 */
	private CommonView() {
		super();
	}

	/**
	 * Return the objects and view for success
	 * 
	 * @param resultMessageKey
	 *            The key of the message to print
	 * @return The view
	 */
	public ModelAndView getSuccessView(String resultMessageKey) {
		// If everything goes fine
		final ModelAndView modelAndView = new ModelAndView("success");
		modelAndView.addObject("resultMessage", resultMessageKey);
		return modelAndView;
	}

}